﻿using System.Collections.Generic;
using Cygida.Environment.DataAccess;
using WallpaperSharing.DataAccess.Interfaces;
using WallpaperSharing.Domain;

namespace WallpaperSharing.DataAccess
{
    public class WallpaperDao : DaoBase, IWallpaperDao
    {
        public WallpaperDao()
            : this(DataSources.Manhattan)
        { }

        public WallpaperDao(IBaseDataSource dataSource)
            : base(dataSource)
        { }

        public IList<Wallpaper> SelectAll()
        {
            return DataSource.QueryForList<Wallpaper>("SelectAllWallpapers", null);
        }

        public Wallpaper SelectById(int id)
        {
            return DataSource.QueryForObject<Wallpaper>("SelectWallpaperById", id);
        }

        public IList<Wallpaper> SelectByCategoryId(int categoryId)
        {
            return DataSource.QueryForList<Wallpaper>("SelectWallpapersByCategoryId", categoryId);
        }

        public void Insert(Wallpaper domain)
        {
            DataSource.Insert("InsertWallpaper", domain);
        }

        public void Update(Wallpaper domain)
        {
            DataSource.Update("UpdateWallpaper", domain);
        }

        public void Delete(int id)
        {
            DataSource.Delete("DeleteWallpaper", id);
        }
    }
}
